package com.example.demo.repository;

import com.example.demo.domain.Goods;
import com.example.demo.domain.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface GoodsMapper
{

    //查询
//    @Select("select * from goods where id=#{id}")
    public Goods getGoodsById(Integer id);
    @Select("select * from goods where state!=2 order by times desc")
    public List<Goods> getAll();

    public List<Goods> getSearch(String searchText);

//    @Select("select * from goods order by times desc limit #{from},#{pageNum}")
    public List<Goods> getByRange(@Param("from")Integer from,@Param("pageNum")Integer pageNum);

    Goods getBaseGoodsbyId(Integer id);

    @Update("update goods set state=2 where id=#{id}")
    void delGoodsChangeStateById(Integer id);

    //增
    void addGoods(Goods goods);

    // 删
    void delGoodsById(Integer id);

    // 改
    void saveGoods(Goods goods);

    @Select("select id from goods where name=#{name}")
    Integer getIdByName(String name);

}
